property intervall : 0
property was : ""
property wohin : ""
property client : ""

on run
	--Einmalig Werte fr Properties abfragen
	if intervall = 0 then
		set intervall to text returned of 
			(display dialog "Bild zum Server bertragen: [Sekunden]" default answer "300")
	end if
	
	if was = "" then
		set was to ((choose file) as string)
	end if
	
	if wohin = "" then
		set wohin to text returned of 
			(display dialog 
				"Wohin sollen die Bilder bertragen werden?" default answer "ftp://user:passwort@ftp.Ihr-Server.de/verzeichnis/")
	end if
	
	if client = "" then
		get (display dialog 
			"Welchen FTP-Client setzen Sie ein?" buttons {"Abbruch", "Anarchie", "NetFinder"} default button "Abbruch")
		if button returned of result  "Abbruch" then
			set client to button returned of result
		end if
	end if
end run


on idle
	--Besteht schon eine Verbindung ins Internet?
	if state of (PPP status) = "Bereit" then
		try
			PPP connect with quiet mode
		on error
			return intervall
		end try
	end if
	
	if wohin  "" then
		--Fr alle Flle einen Timeout setzen
		with timeout of 600 seconds
			
			if client = "Anarchie" then
				tell application "Anarchie"
					store alias was url wohin
				end tell
			else if client = "NetFinder" then
				tell application "NetFinder"
					puturl was to wohin
				end tell
			end if
			
		end timeout
	end if
	
	PPP disconnect
	
	return intervall
end idle